package hlhj.fhp.checkpoint.module

import android.content.Context
import com.example.mymvp.mvp.BaseModule
import com.lzy.okgo.model.Response
import hlhj.fhp.checkpoint.http.Apis
import hlhj.fhp.checkpoint.http.CustomAction
import hlhj.fhp.checkpoint.http.LoadingAction
import hlhj.fhp.checkpoint.javaBean.MoneyBean

/**
 * Created by Never Fear   on 2018\11\12 0012.
Never More....
 */
class MoneyModule :BaseModule {
    var listener:MoneyListener?=null
    fun getMoney(c:Context,page:Int){
        Apis.getMoney(page)
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :CustomAction<Response<MoneyBean>>(c){
                                override fun httpSuccess(t: Response<MoneyBean>) {
                                    listener?.moneyResp(t.body())
                                }
                            })
                }
    }

    interface MoneyListener{
        fun moneyResp(moneyBean: MoneyBean)
    }
}